using System;
using UnityEngine;

namespace BCW.GameTypes.SkyBlock
{
	public class SkyFlag : MonoBehaviour
	{
		public PunTeams.Team team;

		public GameObject flagObject;

		public static event Action<PunTeams.Team> OnFlagCollision;

		private void Awake()
		{
		}

		private void Start()
		{
			SkyBlockController.instance.flags.Add(this);
		}

		private void OnDestroy()
		{
		}

		private void SwitchFlag(PunTeams.Team t, bool val)
		{
			if (t == team)
			{
				flagObject.SetActive(val);
			}
		}

		private void OnTriggerEnter(Collider other)
		{
			PlayerBehavior componentInParent = other.GetComponentInParent<PlayerBehavior>();
			if (componentInParent != null && componentInParent.isMine && SkyFlag.OnFlagCollision != null && !SkyBlockController.instance.hasFlag)
			{
				SkyFlag.OnFlagCollision(team);
			}
		}
	}
}
